<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="css/style.css"/>
		<style type="text/css">
			.mui-table-view {
				/* margin-bottom: 35px; */
				background-color: white;
			}
			.title {margin: 35px 15px 10px;}
			.logo {
				padding: 12px;
			}
			.mui-content{
				background: #FFFFFF;
			}
		</style>
	</head>

	<body>
		<div class="mui-content">
			
			<!--侧栏图片-->
			<div class="content">
				<div class="celan_div">
					<div class="celan_div1">
						<img class="celan_img" src="images/abuts.png" />
					</div>
					<div id="loginInfo" style="z-index: 9999;">
						<center><img class="celan_img1" src="images/logo.png" >
							<h5 style="color: #939eed;"><center id="username">您尚未登录，请登录</center></h5>
							<span style="display: none;" id="detail"><p>获赞：0&nbsp;&nbsp;文章：0</p></span>
							<span style="display: none;" id="skin-detail"><p>D|R|N|T</p></span>
						</center>
					</div>
				</div>
			</div>
			<!--侧栏图片结束 -->
			
			<div class="title" style="margin-bottom: 25px;">&emsp;</div>
			<ul class="mui-table-view mui-table-view-chevron ">
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" href="template/Other/business2-card.html">
						<span class="celan_sp3">●</span>&emsp;参加的
					</a>
				</li>
				<li class="mui-table-view-cell" >
					<a class="mui-navigate-right" data-url="written.html" href="javascript:;">
						<span class="celan_sp4">●</span>&emsp;写过的
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" href="article/">
						<span class="celan_sp5">●</span>&emsp;草稿箱
					</a>
				</li>
				<li class="mui-table-view-cell" >
					<a class="mui-navigate-right" href="template/News/Shopping-list.html">
						<span class="celan_sp6">●</span>&emsp;评论我的
					</a>
				</li>
				<li class="mui-table-view-cell" >
					<a class="mui-navigate-right" href="template/Other/business2-card.html">
						<span class="celan_sp4">●</span>&emsp;回复我的
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" href="setting.html">
						<span class="celan_sp1">●</span>&emsp;我的评论
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" href="template/Other/newtwoadd.html">
						<span class="celan_sp4">●</span>&emsp;收藏
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" href="template/Other/other-emtmenu.html">
						<span class="celan_sp6">●</span>&emsp;帮助
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" href="template/Other/other-Personal-Center.html">
						<span class="celan_sp2">●</span>&emsp;设置
					</a>
				</li>
			</ul>
														
		</div>
		<script src="js/mui.min.js"></script>
		<script src="js/common.js"></script>
		<script src="js/app.js"></script>
		<script type="text/javascript" charset="utf-8">
			var aniShow = "slide-in-right";
			//关于backbutton和menubutton两个按键的说明，在iOS平台不存在，故需隐藏
			if(!mui.os.android) {
				var span = document.getElementById("android-only")
				if(span) {
					span.style.display = "none";
				}
				aniShow = "pop-in";
			}
			var subWebview = null,
				template = null,
				index = null;
			mui.plusReady(function() {
				//获得主页面webview引用；
				index = plus.webview.currentWebview().opener();
				// 设置系统状态栏背景
				// console.log("方法被调用");
				plus.navigator.setStatusBarBackground( "#ff8dae" );
				// 设置系统状态栏样式为浅色文字
				plus.navigator.setStatusBarStyle( "UIStatusBarStyleBlackOpaque" );
				// 获取当前的webview对象
				var curWebview = plus.webview.currentWebview();
				curWebview.addEventListener("show", function() {
					refreshUserInfo();
				});
				
			});
			mui('.mui-table-view').on('tap', 'a', function() {
				var url = this.getAttribute("data-url");
				close();
				mui.openWindow({
					id: url,
					url: url,
					waiting: {
						autoShow: false
					}
				});
			});
		//刷新用户信息
		function refreshUserInfo() {
			
			var user = app.getUserGlobalInfo();
			// 判断本地是否保存有user信息
			var userInfo = app.getUserGlobalInfo();
			// 获得当前的webview，刷新当前用户信息
			var loginInfo=document.getElementById("loginInfo");
			var username=document.getElementById("username");
			var detail=document.getElementById("detail");
			var skindetail=document.getElementById("skin-detail");
			if(userInfo!=null){
				username.innerHTML='welcome,'+userInfo.username;
				// console.log(JSON.stringify(userInfo));
				detail.style.display='block';
				skindetail.style.display='block';
				// console.log(detail.style.display);
			}else{
				username.innerHTML='您尚未登录，请登录';
				detail.style.display = 'none';
				skindetail.style.display = 'none';
			}
			console.log("refresh======="+JSON.stringify(user))
			
			if (user != null) {
				var faceImage = user.faceImage;
				var nickname = user.nickname;
				var username = user.username;
				
				var span_nickname = document.getElementById("span_nickname");
				var span_username = document.getElementById("span_username");
				
				span_username.innerHTML = username;
				
				if (app.isNotNull(faceImage)) {
					var img_my_face = document.getElementById("img_my_face");
					img_my_face.src = app.imgServerUrl + faceImage;
				}
			}
		}	
		//登录信息
		var loginInfo=document.getElementById("loginInfo");
		loginInfo.addEventListener('tap',function(){
			var userInfo = app.getUserGlobalInfo();
			console.log("userInfo===="+userInfo);
			if(userInfo!=null){
				mui.openWindow('me-setting.html','me-setting.html');
			}else{
				// console.log("userInfo===="+userInfo);
				close();
				// var wvs = plus.webview.all();
				// for (var i = 0; i < wvs.length; i++) {
				// 	wvs[i].close();
				// }
				// var loginPage =plus.webview.create('login.html','login.html');
				// loginPage.show();
				// mui.openWindow('login.html','login.html');
				
				//触发load-login自定义事件,打开login页面
				var indexWindow = plus.webview.getLaunchWebview();
				mui.fire(indexWindow,'load-login',{login:'login111'})
				
			}
			
		});
			/**
			 * 关闭侧滑菜单
			 */
			function close() {
				mui.fire(mui.currentWebview.opener(), "menu:close");
			}
			//在android4.4.2中的swipe事件，需要preventDefault一下，否则触发不正常
			window.addEventListener('dragstart', function(e) {
				mui.gestures.touch.lockDirection = true; //锁定方向
				mui.gestures.touch.startDirection = e.detail.direction;
			});
			window.addEventListener('dragleft', function(e) {
				if(!mui.isScrolling) {
					e.detail.gesture.preventDefault();
				}
			});
			//监听左滑事件，若菜单已展开，左滑要关闭菜单；
			window.addEventListener("swipeleft", function(e) {
				if(Math.abs(e.detail.angle) > 170) {
					close();
				}
			});
		</script>
	</body>

</html>